<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>

<body>
    <a href="https://developer.mozilla.org/zh-CN/">mdn</a>
    <a href="javascript:">百度</a>
    <a href="javascript:">aa</a>
    <script>
        a = document.querySelector('a')
        a.onclick = function (e) {
            e.preventDefault ? e.preventDefault() : e.returnValue = false
            // return false  也可以 

        }
    </script>
</body>

</html>